package com.fowo.api.sys.service.helper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fowo.api.sys.entity.SysUser;
import com.fowo.api.sys.mapper.SysUserMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * @fileName: UserHelprt
 * @Description: 代码目的，作用，如何工作
 * @Author: pzh
 * @Date: 2023/4/14 0014 10:29
 */
@Component
public final class UserHelper {
    /**
     * 用户帮助类
     **/
    private static UserHelper userHelper;

    @Resource
    private SysUserMapper userMapper;

    @PostConstruct
    public void init() {
        userHelper = this;
        userHelper.userMapper = this.userMapper;

    }

    public static List<SysUser> queryUserList(List<Long> userIds) {
        if (CollectionUtils.isEmpty(userIds)) {
            return Collections.emptyList();
        }
        LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(SysUser::getId, userIds);
        return userHelper.userMapper.selectList(queryWrapper);
    }
}
